package com.sjgtw.cloud.web.organization.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sjgtw.cloud.common.core.web.controller.BaseController;
import com.sjgtw.cloud.common.core.web.domain.AjaxResult;
import com.sjgtw.cloud.common.core.web.page.TableDataInfo;
import com.sjgtw.cloud.web.organization.domain.Organization;
import com.sjgtw.cloud.web.organization.domain.OrganizationDetails;
import com.sjgtw.cloud.web.organization.service.IOrganizationDetailsService;
import com.sjgtw.cloud.web.organization.service.IOrganizationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 应急组织管理Controller
 * 
 * @author ruoyi
 * @date 2024-03-15
 */
@RestController
@Api(tags = "1.10、应急组织管理")
@RequestMapping("/organization")
public class OrganizationController extends BaseController
{
    @Autowired
    private IOrganizationService organizationService;

    @Autowired
    private IOrganizationDetailsService  organizationDetailsService;

    /**
     * 查询应急组织管理列表
     */

    @GetMapping("/list")
    @ApiOperation("列表")
    public TableDataInfo list(Organization organization)
    {
        startPage();
        JSONArray list = organizationService.selectOrganizationList(organization);
        return getDataTable(list);
    }

    /**
     * 新增应急组织管理
     */

    @PostMapping("/add")
    @ApiOperation("新增组织，返回id，跳转到详情")
    public JSONObject add(@RequestBody Organization organization)
    {
        return organizationService.insertOrganization(organization);
    }


    /**
     * 新增应急组织管理详情,点击确认按钮
     */

    @PostMapping("/addDetails")
    @ApiOperation("点击详情确认保存")
    public AjaxResult addDetails(@RequestBody JSONObject organizationDetails)
    {
        return toAjax(organizationService.addDetails(organizationDetails));
    }


    /**
     * 删除应急组织管理
     */
    @ApiOperation("删除")
    @DeleteMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(organizationService.deleteOrganizationById(id));
    }



}
